<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import predictionDriverSign from '@/api/prediction/predictionDriverSign'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()


const numberOperation = (newValue, id, numberName) => {
  predictionDriverSign.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  predictionDriverSign.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  id: 'flyos_prediction_driver_sign',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: predictionDriverSign.getList,
  recycleApi: predictionDriverSign.getRecycleList,
  add: {
    show: true,
    api: predictionDriverSign.save,
    auth: ['prediction:driverSign:save']
  },
  edit: {
    show: true,
    api: predictionDriverSign.update,
    auth: ['prediction:driverSign:update']
  },
  delete: {
    show: true,
    api: predictionDriverSign.deletes,
    auth: ['prediction:driverSign:delete'],
    realApi: predictionDriverSign.realDeletes,
    realAuth: ['prediction:driverSign:realDeletes']
  },
  recovery: {
    show: true,
    api: predictionDriverSign.recoverys,
    auth: ['prediction:driverSign:recovery']
  },
  import: {
    show: true,
    url: 'prediction/driverSign/import',
    templateUrl: 'prediction/driverSign/downloadTemplate',
    auth: ['prediction:driverSign:import']
  },
  export: {
    show: true,
    url: 'prediction/driverSign/export',
    auth: ['prediction:driverSign:export']
  }
})

const columns = reactive([
  {
    title: "ID",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入ID"
    }
  },
  {
    title: "用户ID",
    dataIndex: "user_id",
    formType: "input",
    search: true
  },
  {
    title: "纬度",
    dataIndex: "lat",
    formType: "input",
    search: true
  },
  {
    title: "经度",
    dataIndex: "lng",
    formType: "input",
    search: true
  },
  {
    title: "签到地点",
    dataIndex: "sign_address",
    formType: "input",
    search: true
  },
  {
    title: "车牌号码",
    dataIndex: "car_no",
    formType: "input",
    search: true
  },
  {
    title: "签到状态",
    dataIndex: "sign_status",
    formType: "input",
    search: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    search: true,
    addDisplay: false,
    editDisplay: false,
    sortable: {
      sortDirections: [
        "ascend",
        "descend"
      ],
      sorter: true
    },
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'prediction:driverSign' } </script>